//
//  ViewController.m
//  03-FMDB(多线程)
//
//  Created by whitcast on 16/6/23.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "ViewController.h"
#import "HMStudent.h"
#import "HMStudentDBTool.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        HMStudent *student = [[HMStudent alloc] init];
        student.name = @"大大泡泡糖";
        student.age = 15;
        
        [HMStudentDBTool insertStudent:student];
        
        NSLog(@"1 %@",[NSThread currentThread]);
    });
    
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        HMStudent *student = [[HMStudent alloc] init];
        student.name = @"小泽";
        student.age = 12;
        
        [HMStudentDBTool insertStudent:student];
        
        NSLog(@"2 %@",[NSThread currentThread]);
    });

    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        HMStudent *student = [[HMStudent alloc] init];
        student.name = @"老王";
        student.age = 20;
        
        [HMStudentDBTool insertStudent:student];
        
        NSLog(@"3 %@",[NSThread currentThread]);
    });

}

@end
